package com.yfp.operation.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.utils.poi.ExcelUtil;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.common.core.web.page.TableDataInfo;
import com.yfp.operation.domain.dto.MealReplacementDTO;
import com.yfp.operation.domain.vo.MealReplacementVO;
import com.yfp.operation.service.MealReplacementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/mealReplacement")
@Tag(name = "打卡活动")
public class MealReplacementController extends BaseController {

    @Resource
    private MealReplacementService mealReplacementService;

    @GetMapping("/list")
    @Operation(summary = "获取客服在线记录")
    public R<TableDataInfo<List<MealReplacementVO>>> searchList(MealReplacementDTO mealReplacementDTO) {
        startPage();
        List<MealReplacementVO> activitySignInsList = mealReplacementService.searchList(mealReplacementDTO);
        TableDataInfo<List<MealReplacementVO>> dataTable = getDataTable(activitySignInsList);
        return R.ok(dataTable);
    }


    @PostMapping("/export")
    @Operation(summary = "获取客服在线记录-导出", description = "数据导出")
    public void export(HttpServletResponse response, @ModelAttribute MealReplacementDTO mealReplacementDTO) {
        List<MealReplacementVO> activitySignInsList = mealReplacementService.searchList(mealReplacementDTO);
        ExcelUtil<MealReplacementVO> util = new ExcelUtil<MealReplacementVO>(MealReplacementVO.class);
        util.exportExcel(response, activitySignInsList, "客服在线记录");
    }

}
